home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / pmake / biglib.mk < prev    next >
Text File  |  1992-04-13  |  11KB  |  403 lines

  1. #
  2. # Included makefile for managing libraries.  This makefile is used as
  3. # an include files in large libraries (like the C library) that consist
  4. # of several source subdirectories, each potentially with machine-
  5. # dependent subdirectories.
  6. #
  7. # $Header: /sprite/lib/pmake/RCS/biglib.mk,v 1.70 92/04/13 18:33:47 elm Exp $ SPRITE (Berkeley)
  8. #
  9. # The makefile that includes this one should already have defined the
  10. # following variables:
  11. #    NAME        base name of library (e.g. tcl, sx, c, etc.).  Since
  12. #            this directory only has a piece of the library, NAME
  13. #            is the name of the parent directory.
  14. #    SUBDIR        the name of this directory
  15. #    SRCS        all sources for library for the current target
  16. #            machine
  17. #    ALLSRCS        all sources for the library, including all sources
  18. #            for all target machines
  19. #    HDRS        all header files (public and private)
  20. #    OBJS        object files from which to create it
  21. #    CLEANOBJS    object files to be removed as part of "make clean"
  22. #            (need not just be object files)
  23. #    PUBHDRS        publicly-available headers for the library (this
  24. #            contains only machine-independent headers)
  25. #    MDPUBHDRS    machine-dependent public headers for the library
  26. #            (for the current TM)
  27. #    LINTSRCS    additional sources to be used only when generating
  28. #            lint library
  29. #    TM        target machine type for object files etc.
  30. #    MACHINES    list of all target machines currently available
  31. #            for this program
  32. #    TYPE        a keyword identifying which sort of library this
  33. #            is;  used to determine where to install, etc.
  34. #
  35. # Optional variables that may be defined by the invoker:
  36. #    XAFLAGS        additional flags to pass to assembler
  37. #    XCFLAGS        additional flags to pass to compiler
  38. #    DEPFLAGS    additional flags to pass to makedepend
  39. #    no_targets    if defined, this file will not define all of the
  40. #            basic targets (make, make clean, etc.)
  41. #
  42. #
  43.  
  44. #
  45. # The variables below should be defined in md.mk, but they are given
  46. # default values just in case md.mk doesn't exist yet.
  47. #
  48. CLEANOBJS    ?=
  49. HDRS        ?=
  50. MANPAGES    ?=
  51. MDPUBHDRS    ?=
  52. OBJS        ?=
  53. SRCS        ?=
  54.  
  55. #
  56. # Define search paths for include files and source files (for sources,
  57. # must be sure to look both in this directory and in the machine-dependent
  58. # one).
  59. #
  60. .PATH.a        : # Clear out previous, or Pmake will not look in the
  61.           # right place for files like $(REGLIB)!!  This is
  62.           # a gross bug in Pmake.
  63. .PATH.h        : # Clear out previous
  64. .PATH.h        : $(TM).md /sprite/lib/include /sprite/lib/include/$(TM).md
  65. .PATH.c        : # Clear out previous
  66. .PATH.c        : $(TM).md
  67. .PATH.s        : # Clear out previous
  68. .PATH.s        : $(TM).md
  69.  
  70. #
  71. # System programs -- assign conditionally so they may be redefined in
  72. # including makefile
  73. #
  74. BINDIR        = /sprite/cmds.$(MACHINE)
  75.  
  76. AS        ?= $(BINDIR)/as
  77. CC        ?= $(BINDIR)/cc
  78. CHGRP        ?= $(BINDIR)/chgrp
  79. CHMOD        ?= $(BINDIR)/chmod
  80. CHOWN        ?= $(BINDIR)/chown
  81. CP        ?= $(BINDIR)/cp
  82. CPP        ?= $(BINDIR)/cpp -traditional -$
  83. CTAGS        ?= $(BINDIR)/ctags
  84. ECHO        ?= $(BINDIR)/echo
  85. LINT        ?= $(BINDIR)/lint
  86. MAKEDEPEND    ?= $(BINDIR)/makedepend
  87. MV        ?= $(BINDIR)/mv
  88. RANLIB        ?= $(BINDIR)/ranlib
  89. RM        ?= $(BINDIR)/rm
  90. SED        ?= $(BINDIR)/sed
  91. TEST            ?= $(BINDIR)/test
  92. TOUCH        ?= $(BINDIR)/touch
  93. UPDATE        ?= $(BINDIR)/update
  94.  
  95. # The Ultrix ar doesn't handle truncated file names correctly.
  96.  
  97. #if !empty(MACHINE:Mds3100) || !empty(MACHINE:Mds5000)
  98. AR = $(BINDIR)/ar.sprite
  99. #else
  100. AR = $(BINDIR)/ar
  101. #endif
  102.  
  103. #
  104. # Several variables (such as where to install) are set based on the
  105. # TYPE variable.  Of course, any of these variables can be overridden
  106. # by explicit assignments.
  107. #
  108. TYPE        ?= unknown
  109. #if !empty(TYPE:Msprite)
  110. INCLUDEDIR    ?= /sprite/lib/include
  111. INSTALLMAN    ?= /sprite/man/lib/$(NAME)
  112. #elif !empty(TYPE:Mx)
  113. INCLUDEDIR    ?= /X/lib/include
  114. INSTALLMAN    ?= /X/man/lib/$(NAME)
  115. #elif !empty(TYPE:MX11R3)
  116. INCLUDEDIR    ?= /mic/X11R3/lib/include/X11
  117. INSTALLMAN    ?= /mic/X11R3/man/lib/$(NAME)
  118. #elif !empty(TYPE:MX11R4)
  119. INCLUDEDIR    ?= /X11/R4/lib/include/X11
  120. INSTALLMAN    ?= /X11/R4/man/lib/$(NAME)
  121. #endif
  122.  
  123. #
  124. # Figure out what stuff we'll pass to sub-makes.
  125. #
  126. PASSVARS    = 'INSTALLDIR=$(INSTALLDIR)' $(.MAKEFLAGS)
  127. #ifdef        XCFLAGS
  128. PASSVARS    += 'XCFLAGS=$(XCFLAGS)'
  129. #endif
  130. #ifdef        XAFLAGS
  131. PASSVARS    += 'XAFLAGS=$(XAFLAGS)'
  132. #endif
  133.  
  134. #
  135. # Flags everyone should have. XCFLAGS and XAFLAGS are provided for
  136. # the user to add flags for CC, AS or LINT from the command line.
  137. #
  138.  
  139. #include    <tm.mk>
  140. CTFLAGS        ?= -wt
  141. DEPFLAGS    ?=
  142. INSTALLFLAGS    ?=
  143. INSTALLMANFLAGS    ?=
  144. LINTFLAGS    ?= -m$(TM)
  145. LINTFLAGS    += -u -M
  146. XCFLAGS        ?=
  147. XAFLAGS        ?=
  148. #
  149. # The .INCLUDES variable already includes directories that should be
  150. # used by cc and other programs by default.  Remove them, just so that
  151. # the output looks cleaner.
  152. #
  153.  
  154. #
  155. # The ds3100 port is not ready for the -O yet.
  156. #
  157.  
  158. #if !empty(TM:Mds3100)
  159. CFLAGS        += -O $(TMCFLAGS) $(XCFLAGS) -I.
  160. GFLAG        = -g3
  161. #elif !empty(TM:Mspur)
  162. CFLAGS        += $(TMCFLAGS) $(XCFLAGS) -I.
  163. GFLAG        =
  164. #else
  165. CFLAGS        += -O $(TMCFLAGS) $(XCFLAGS) -I.
  166. GFLAG        = -g
  167. #endif
  168.  
  169. #
  170. # Since the dec compiler doesn't include /sprite/lib/include we must leave
  171. # the path as is when TM=ds3100.
  172. #
  173.  
  174. CFLAGS        += $(.INCLUDES:S|^-I/sprite/lib/include$||g:S|^-I/sprite/lib/include/$(TM).md$||g)
  175. #if empty(TM:Mds3100)
  176. AFLAGS        += $(TMAFLAGS) $(XAFLAGS)
  177. #else
  178. CFLAGS        += -I/sprite/lib/include -I/sprite/lib/include/$(TM).md
  179. AFLAGS        += $(.INCLUDES)
  180. #endif
  181.  
  182. .MAKEFLAGS    : -C
  183.  
  184. #
  185. # The c library is used by the kernel.  Since the kernel does not
  186. # use the floating point coprocessor, the c library must be compiled
  187. # to use software floating point.  This isn't any big deal because
  188. # there isn't very much floating point stuff in libc anyway.
  189. #
  190.  
  191. #if !empty(TM:Msun3) && !empty(NAME:Mc)
  192. CFLAGS          += -msoft-float
  193. #endif
  194.  
  195. #
  196. # Define the various types of libraries we can make to make our rules and
  197. # maybe the user's easier to write.
  198. #
  199. REGLIB        = ../$(TM).md/lib$(NAME).a
  200. PROFLIB        = ../$(TM).md/lib$(NAME)_p.a
  201. DEBUGLIB    = ../$(TM).md/lib$(NAME)_g.a
  202. LINTLIB        = llib-l$(SUBDIR).ln
  203.  
  204. #
  205. # Figure out which files to use in cases where the file may be either
  206. # machine-dependent or machine-independent
  207. #
  208.  
  209. DEPFILE        = $(TM).md/dependencies.mk
  210. LINTFILE    = $(TM).md/lint
  211.  
  212. #
  213. # Transformation rules: these have special features to place .o files
  214. # in md subdirectories, run preprocessor over .s files, and generate
  215. # .po files for profiling.
  216. #
  217.  
  218. .SUFFIXES    : .po .go
  219.  
  220. .c.o        :
  221.     $(RM) -f $(.TARGET)
  222.     $(CC) $(CFLAGS) -c $(.IMPSRC) -o $(.TARGET)
  223. .c.po        :
  224.     $(RM) -f $(.TARGET)
  225. #ifdef NOPROFILE        
  226.     $(CC) $(CFLAGS) -DPROFILE -c $(.IMPSRC) -o $(.TARGET)
  227. #else        
  228.     $(CC) $(CFLAGS) -p -DPROFILE -c $(.IMPSRC) -o $(.TARGET)
  229. #endif               
  230.  
  231. .c.go        :
  232.     $(RM) -f $(.TARGET)
  233.     $(CC) $(CFLAGS) $(GFLAG) -c $(.IMPSRC) -o $(.TARGET)
  234. .s.go .s.po .s.o    :
  235. #if empty(TM:Mds3100)
  236.     $(CPP) $(CFLAGS:M-[IDU]*) -D$(TM) -m$(TM) -D_ASM $(.IMPSRC) > $(.PREFIX).pp
  237.     $(AS) -o $(.TARGET) $(AFLAGS) $(.PREFIX).pp
  238.     $(RM) -f $(.PREFIX).pp
  239. #else 
  240.     $(RM) -f $(.TARGET)
  241.     $(AS) $(AFLAGS) $(.IMPSRC) -o $(.TARGET)
  242. #endif
  243.  
  244. #
  245. # The rule below is needed to make archives, so that the archive
  246. # member depends on the corresponding .o (or .po) file.  For some
  247. # reason, this rule doesn't work without some commands (and the ...
  248. # is enough).
  249. .go.a .po.a .o.a    :
  250.     ...
  251.  
  252. #
  253. # MAKEINSTALLHDRS usage:
  254. #    <target> : MAKEINSTALLHDRS
  255. # All of the public headers files get updated to INCLUDEDIR.
  256. #
  257. MAKEINSTALLHDRS    : .USE .SILENT
  258. #if !empty(PUBHDRS)
  259.     $(UPDATE) -l -m 664 -t $(INSTALLFLAGS) $(PUBHDRS) $(INCLUDEDIR)
  260. #endif
  261. #if !empty(MDPUBHDRS)
  262.     $(UPDATE) -l -m 664 -t $(INSTALLFLAGS) \
  263.         $(MDPUBHDRS) $(INCLUDEDIR)/$(TM).md
  264. #endif
  265.  
  266. #
  267. # MAKELINT usage:
  268. #    <fluff-file> : <sources to be linted> MAKELINT
  269. #
  270. # <fluff-file> is the place to store the output from the lint.
  271. #
  272. MAKELINT    : .USE
  273.     $(RM) -f $(.TARGET)
  274.     $(LINT) $(LINTFLAGS) $(CFLAGS:M-[IDU]*) $(.ALLSRC:M*.c) \
  275.         > $(.TARGET) 2>&1
  276. #
  277. # MAKEDEPEND usage:
  278. #    <dependency-file> : <sources> MAKEDEPEND
  279. #
  280. # Generate dependency file suitable for inclusion in future makes.
  281.  
  282. MAKEDEPEND    : .USE
  283.     @$(TOUCH) $(DEPFILE)
  284.     $(MAKEDEPEND) $(CFLAGS:M-[ID]*) -m $(TM) -w80 -f $(DEPFILE) $(.ALLSRC)
  285.     @$(MV) -f $(DEPFILE) $(DEPFILE).tmp
  286.     @$(SED) -e '/^#/!s|^\([^:]*\)\.o[     ]*:|$(TM).md/\1.po $(TM).md/\1.go $(TM).md/&|' <$(DEPFILE).tmp > $(DEPFILE)
  287.     @$(RM) -f $(DEPFILE).tmp
  288.  
  289. #ifndef no_targets
  290. #
  291. # Define all the main targets.  See the Mkmf man page for details.
  292. #
  293. default            : $(REGLIB)
  294. $(REGLIB)        : $(REGLIB)($(OBJS)) .PRECIOUS
  295.     $(AR) $(ARFLAGS) $(.TARGET) $(.OODATE)
  296.     ...
  297.     $(RANLIB) $(.TARGET)
  298. #if !empty(CLEANOBJS:M*.o) && empty(TM:Mds3100)
  299.     rm -rf $(CLEANOBJS:M*.o)
  300. #endif
  301.  
  302. # Rebuild is used to remake from scratch, doing ar q instead of ar r
  303. # to make it fast, and doing only a single ranlib at the top level
  304. #
  305. rebuild        : $(REGLIB)($(OBJS)) .PRECIOUS
  306.     $(AR) q $(REGLIB) $(.OODATE)
  307.  
  308. debug            : $(DEBUGLIB)
  309. $(DEBUGLIB)        : $(DEBUGLIB)($(OBJS:S/.o$/.go/g)) .PRECIOUS
  310.     $(AR) $(ARFLAGS) $(.TARGET) $(.OODATE)
  311.     ...
  312.     $(RANLIB)  $(.TARGET)
  313. #if !empty(CLEANOBJS:M*.o) && empty(TM:Mds3100)
  314.     rm -rf $(CLEANOBJS:M*.o:S/.o$/.go/g)
  315. #endif
  316.  
  317. clean            ! .IGNORE
  318.     $(RM) -f $(CLEANOBJS) $(CLEANOBJS:M*.o:S/.o$/.po/g) \
  319.         $(CLEANOBJS:M*.o:S/.o$/.go/g) $(TM).md/$(LINTLIB) \
  320.         $(LINTFILE) y.tab.c lex.yy.c core a.out *~ \
  321.         $(TM).md/*~ version.h
  322.     $(AR) d $(REGLIB) $(OBJS)
  323.     $(RANLIB) $(REGLIB)
  324.     $(AR) d $(PROFLIB) $(OBJS:S/.o$/.po/g)
  325.     $(RANLIB) $(PROFLIB)
  326.     $(AR) d $(DEBUGLIB) $(OBJS:S/.o$/.go/g)
  327.     $(RANLIB) $(DEBUGLIB)
  328.  
  329. depend            :: $(DEPFILE)
  330. $(DEPFILE)        ! $(SRCS:M*.c) $(SRCS:M*.s) $(SRCS:M*.cc) MAKEDEPEND
  331.  
  332. install            :: $(REGLIB) installhdrs installman lintlib
  333. installdebug        :: $(DEBUGLIB)
  334. installhdrs        :: MAKEINSTALLHDRS
  335. #if empty(MANPAGES)
  336. installman        :: .SILENT
  337.     echo "No man pages for library $(NAME)/$(SUBDIR)?  Please write some."
  338. #elif !empty(MANPAGES:MNONE)
  339. installman        ::
  340.  
  341. #elif defined(INSTALLMAN)
  342. installman        :: .SILENT
  343.     $(UPDATE) -m 444 -l $(INSTALLMANFLAGS) $(MANPAGES) $(INSTALLMAN)
  344. #else
  345. installman        :: .SILENT
  346.     echo "Can't install man page(s): no install directory defined"
  347. #endif
  348. installprofile        :: $(PROFLIB)
  349.  
  350. lint            :: $(LINTFILE)
  351. $(LINTFILE)        : $(SRCS:M*.c) $(HDRS) MAKELINT
  352.  
  353. lintlib            :: $(TM).md/$(LINTLIB)
  354. $(TM).md/$(LINTLIB)    : $(SRCS:M*.c) $(HDRS) $(LINTSRCS)
  355.     $(RM) -f $(.TARGET) llib-l$(SUBDIR).ln
  356.     $(LINT) -C$(NAME) $(CFLAGS:M-[IDU]*) -DLINTLIB $(LINTFLAGS) \
  357.         $(SRCS:M*.c) $(LINTSRCS)
  358.     $(MV) llib-l$(NAME).ln $(.TARGET)
  359.  
  360. mkmf            ! .SILENT
  361.     mkmf
  362.  
  363. newtm            ! .SILENT
  364.     if $(TEST) -d $(TM).md; then
  365.         true
  366.     else
  367.         mkdir $(TM).md;
  368.         chmod 775 $(TM).md;
  369.         mkmf -m$(TM)
  370.     fi
  371.  
  372. profile            :: $(PROFLIB)
  373. $(PROFLIB)        : $(PROFLIB)($(OBJS:S/.o$/.po/g)) .PRECIOUS
  374.     $(AR) $(ARFLAGS) $(.TARGET) $(.OODATE)
  375.     ...
  376.     $(RANLIB)  $(.TARGET)
  377. #if !empty(CLEANOBJS:M*.o) && empty(TM:Mds3100)
  378.     rm -rf $(CLEANOBJS:M*.o:S/.o$/.po/g)
  379. #endif
  380.  
  381. tags            :: $(ALLSRCS:M*.c) $(HDRS)
  382.     $(CTAGS) $(CTFLAGS) $(ALLSRCS:M*.c)
  383.  
  384. DISTFILES    ?=
  385.  
  386. dist        !
  387. #if defined(DISTDIR) && !empty(DISTDIR)
  388.     for i in Makefile local.mk $(TM).md/md.mk \
  389.         $(MANPAGES) $(SRCS) $(HDRS) $(DISTFILES)
  390.     do
  391.     if $(TEST) -e $${i}; then
  392.         $(UPDATE)  $${i} $(DISTDIR)/$${i} ;else true; fi
  393.     done
  394. #else
  395.     @echo "Sorry, no distribution directory defined"
  396. #endif
  397.  
  398. #include        <all.mk>
  399. #endif no_targets
  400.  
  401. #include        <rdist.mk>
  402.